<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<html>
<%@ include file="../inc/Title.jsp"%>
<head>
<script src="/calendar/calendar.js"></script>
<script language="javascript">
	function checkInput(){
		if(window.event.keyCode==13){
			doOk();
		}
	}
	function doOk(){
		var str="search_type=1";
		
		if(document.getElementById("cb_adjust_date").checked){
			var startDate=document.getElementById("start_date").value;
			if(startDate==null || startDate==''){
				alert("请选择调账开始日期");
				return;
			}else{
				var arr=startDate.split("-");
				if(arr.length==null || arr.length!=3){
					alert("调账开始日期格式不正确");
					return;
				}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
					alert("调账开始日期格式不正确");
					return;
				}
			}
			var endDate=document.getElementById("end_date").value;
			if(endDate==null || endDate==''){
				alert("请选择调账结束日期");
				return;
			}else{
				var arr=endDate.split("-");
				if(arr.length==null || arr.length!=3){
					alert("调账结束日期格式不正确");
					return;
				}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
					alert("调账结束日期格式不正确");
					return;
				}
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_adjust_date=1&start_date="+startDate+"&end_date="+endDate;
		}
		if(document.getElementById("cb_examine").checked){
			var examined="A";
			if(document.getElementById("examine1").checked){
				examined="Y";
			}else if(document.getElementById("examine2").checked){
				examined="N";
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_examine=1&examined="+examined;
		}
		if(document.getElementById("cb_manager").checked){
			var managerName=document.getElementById("manager_name").value;
			if(managerName==null || managerName==""){
				alert("请输入经办人姓名");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_manager=1&manager_name="+encodeURIComponent(managerName);
		}
		if(document.getElementById("cb_est").checked){
			var estName=document.getElementById("est_name").value;
			if(estName==null || estName==""){
				alert("请输入调账单位");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_est=1&est_name="+encodeURIComponent(estName);
		}
		if(document.getElementById("cb_bill_code").checked){
			var billCode=document.getElementById("bill_code").value;
			if(billCode==null || billCode==""){
				alert("请输入调账单号");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_bill_code=1&bill_code="+encodeURIComponent(billCode);
		}
		if(document.getElementById("cb_dep").checked){
			var department=document.getElementById("department").value;
			if(department==null || department=="" || department=="0"){
				alert("请选择部门");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_dep=1&department="+department;
		}
		if(document.getElementById("cb_cost").checked){
			var minCost=document.getElementById("min_cost").value;
			if(minCost==null || minCost==""){
				alert("请输入最小金额");
				return;
			}else if(isNaN(minCost)){
				alert("最小金额只能是数字");
				return;
			}
			var maxCost=document.getElementById("max_cost").value;
			if(maxCost==null || maxCost==""){
				alert("请输入最大金额");
				return;
			}else if(isNaN(maxCost)){
				alert("最大金额只能是数字");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_cost=1&min_cost="+minCost+"&max_cost="+maxCost;
		}
		if(document.getElementById("cb_adjust_type").checked){
			var adjustType=document.getElementById("adjust_type").value;
			if(adjustType==null || adjustType==""){
				alert("请选择调账类型");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_adjust_type=1&adjust_type="+adjustType;
		}
		if(document.getElementById("cb_ts").checked){
			var tsId=document.getElementById("ts_id").value;
			if(tsId==null || tsId=="" || tsId=="0"){
				alert("请选择帐套");
				return;
			}
			if(str!=""){
				str=str+"&";
			}
			str=str+"cb_ts=1&ts_id="+tsId;
		}
		window.location="/finance/AdjustBillSearchResult.ihtm?"+str;
	}
	function doCancel(){
		window.close();
	}
	function checkCbChange(obj){
		if(obj.id=="cb_adjust_date"){
			if(obj.checked){
				document.getElementById("start_date").disabled=false;
				document.getElementById("end_date").disabled=false;
			}else{
				document.getElementById("start_date").disabled=true;
				document.getElementById("end_date").disabled=true;
			}
		}else if(obj.id=="cb_examine"){
			if(obj.checked){
				document.getElementById("examine1").disabled=false;
				document.getElementById("examine2").disabled=false;
				document.getElementById("examine3").disabled=false;
			}else{
				document.getElementById("examine1").disabled=true;
				document.getElementById("examine2").disabled=true;
				document.getElementById("examine3").disabled=true;
			}
		}else if(obj.id=="cb_manager"){
			if(obj.checked){
				document.getElementById("manager_name").disabled=false;
			}else{
				document.getElementById("manager_name").disabled=true;
			}
		}else if(obj.id=="cb_est"){
			if(obj.checked){
				document.getElementById("est_name").disabled=false;
			}else{
				document.getElementById("est_name").disabled=true;
			}
		}else if(obj.id=="cb_bill_code"){
			if(obj.checked){
				document.getElementById("bill_code").disabled=false;
			}else{
				document.getElementById("bill_code").disabled=true;
			}
		}else if(obj.id=="cb_dep"){
			if(obj.checked){
				document.getElementById("department").disabled=false;
			}else{
				document.getElementById("department").disabled=true;
			}
		}else if(obj.id=="cb_cost"){
			if(obj.checked){
				document.getElementById("min_cost").disabled=false;
				document.getElementById("max_cost").disabled=false;
			}else{
				document.getElementById("min_cost").disabled=true;
				document.getElementById("max_cost").disabled=true;
			}
		}else if(obj.id=="cb_adjust_type"){
			if(obj.checked){
				document.getElementById("adjust_type").disabled=false;
			}else{
				document.getElementById("adjust_type").disabled=true;
			}
		}else if(obj.id=="cb_ts"){
			if(obj.checked){
				document.getElementById("ts_id").disabled=false;
			}else{
				document.getElementById("ts_id").disabled=true;
			}
		}
	}
</script>
</head>
<body oncontextmenu="return false">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td align="center" valign="top">
			
			<c:set var="pageTopTitle" value="调账单查询" />
			<c:set var="pageTopMark" value="通过调账单查询，可以对调账单进行编辑，查看调账单的状态" />
			<%@ include file="../inc/PageTop.jsp"%>
			
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center" class="ListTable">
				<tr class="ListTr">
					<td width="1" class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_adjust_date" id="cb_adjust_date" checked="true" onClick="checkCbChange(this);">
					</td>
					<td width="80" class="ListTd FontSmall_Bold">
						调账日期
					</td>
					<td class="ListTd FontSmall">
						从<input type="text" maxlength="15" size="10" onKeyUp="checkInput();" id="start_date" name="start_date" value="${start_date}">
						<img src="/images/calendar.gif" style="cursor:hand" onClick="fPopUpCalendarDlg('/calendar/','start_date');">
						至<input type="text" maxlength="15" size="10" onKeyUp="checkInput();" id="end_date" name="end_date" value="${end_date}">
						<img src="/images/calendar.gif" style="cursor:hand" onClick="fPopUpCalendarDlg('/calendar/','end_date');">
						（格式：2008-01-01）
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_examine" id="cb_examine" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						审核状态
					</td>
					<td class="ListTd FontSmall">
						<input type="radio" name="examined" id="examine1" checked="true" disabled="true">已审核
						<input type="radio" name="examined" id="examine2" disabled="true">未审核
						<input type="radio" name="examined" id="examine3" disabled="true">全部
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_manager" id="cb_manager" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						经办人员
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="15" name="manager_name" id="manager_name" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_est" id="cb_est" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						调账单位
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="50" name="est_name" id="est_name" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_bill_code" id="cb_bill_code" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						调账单号
					</td>
					<td class="ListTd FontSmall">
						<input type="text" maxlength="50" name="bill_code" id="bill_code" onKeyUp="checkInput();" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_dep" id="cb_dep" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						部门
					</td>
					<td class="ListTd FontSmall">
						<select name="department" id="department" disabled="true">
							<option value="0">==请选择==</option>
			  				<commonTag:createSelectTree list="${departmentList}" emptyOption="0" />
			  			</select>
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_cost" id="cb_cost" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						付款金额
					</td>
					<td class="ListTd FontSmall">
						从<input type="text" maxlength="15" onKeyUp="checkInput();" id="min_cost" name="min_cost" disabled="true">
						至<input type="text" maxlength="15" onKeyUp="checkInput();" id="max_cost" name="max_cost" disabled="true">
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_adjust_type" id="cb_adjust_type" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						调账类型
					</td>
					<td class="ListTd FontSmall">
						<select name="adjust_type" id="adjust_type" disabled="true">
							<option value="">==请选择==</option>
			  				<option value="COLLECT_ADD">应收款增加</option>
			  				<option value="COLLECT_ABATE">应收款减少</option>
							<option value="PAY_ADD">应付款增加</option>
			  				<option value="PAY_ABATE">应付款减少</option>
							<option value="PUR_BACK_ADD">采购退货金额增加</option>
			  				<option value="PUR_BACK_ABATE">采购退货金额减少</option>
			  			</select>
					</td>
				</tr>
				<tr class="ListTr">
					<td class="ListTd FontSmall_Bold">
						<input type="checkbox" name="cb_ts" id="cb_ts" onClick="checkCbChange(this);">
					</td>
					<td class="ListTd FontSmall_Bold">
						账套
					</td>
					<td class="ListTd FontSmall">
						<select name="ts_id" id="ts_id" disabled="true">
							<option value="0">==请选择==</option>
							<c:forEach var="item" items="${tsList}">
								<option value="${item.id}">${item.title}</option>
							</c:forEach>
			  			</select>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td height="10" align="center">
			<table width="98%" border="0" cellpadding="0" cellspacing="0">
				<tr><td align="center" bgcolor="#666666" height="1"></td></tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr class="ListTr">
					<td>
						<input type="button" class="Button" value=" 确 定 " onClick="doOk();">
						<input type="button" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>


</body>
</html>